﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BRS.BidModule
{
    public partial class AddTender : Form
    {
        Entities brs = new Entities();
        public AddTender()
        {
            InitializeComponent();
            this.comboBox1.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(textBox1.Text))
            {
                TenderMsg Msg = new TenderMsg()
                {
                    Name = this.textBox1.Text,
                    Type = this.comboBox1.SelectedItem.ToString(),///IsDel = this.checkBox1.Checked,
                    AddTime = DateTime.Now


                };
                if (brs.TenderMsg.Where(p => p.Name == Msg.Name && p.Type == Msg.Type).Count() > 0)
                {
                    MessageBox.Show("此信息已经存在，请检查输入！");
                }
                else
                {
                    brs.TenderMsg.Add(Msg);
                    var ok = brs.SaveChanges();
                    if (ok > 0) MessageBox.Show("添加招标信息成功！");
                }

            }
        }
    }
}
